//
//  ZhuXiaoViewController.m
//  markmap
//
//  Created by 甘世清 on 2024/4/4.
//

#import "ZhuXiaoViewController.h"
#import "LoginViewController.h"
@interface ZhuXiaoViewController ()
@property (nonatomic , strong)SQCustomButton * rightBtn;
@end

@implementation ZhuXiaoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.zx_navTitle = SQNSLocalString(@"注销账号");
}

- (void)SQ_UIViewForSelfView{
    
    UILabel * label = [[UILabel alloc]init];
    label.textColor = UIColor.whiteColor;
    label.numberOfLines = 0;
    label.text = SQNSLocalString(@"为保证您的账号权益,在你提交注销前,请认真阅读以下内容");
    label.font = FONT_BOLD(20);
    [self.view addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.zx_navBar.mas_bottom).offset(40);
            make.height.mas_equalTo(54);
            make.centerX.equalTo(self.view);
            make.width.mas_equalTo(SCREEN_WIDETH - 60);
    }];
    
    UILabel * label1 = [[UILabel alloc]init];
    label1.textColor = UIColor.whiteColor;
    label1.numberOfLines = 0;
    label1.text = SQNSLocalString(@"1: 注销操作为不可逆操作,一旦申请该账号将无法找回!");
    label1.font = FONT_REGULAR(14);
    [self.view addSubview:label1];
    [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(label.mas_bottom).offset(26);
            make.centerX.equalTo(self.view);
            make.width.mas_equalTo(SCREEN_WIDETH - 60);
    }];
    
    UILabel * label2 = [[UILabel alloc]init];
    label2.textColor = UIColor.whiteColor;
    label2.numberOfLines = 0;
    label2.text = SQNSLocalString(@"2: 注销后您的所有权限与数据都将自动清空!");
    label2.font = FONT_REGULAR(14);
    [self.view addSubview:label2];
    [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(label1.mas_bottom).offset(26);
            make.centerX.equalTo(self.view);
            make.width.mas_equalTo(SCREEN_WIDETH - 60);
    }];
    
    UILabel * label3 = [[UILabel alloc]init];
    label3.textColor = UIColor.whiteColor;
    label3.numberOfLines = 0;
    label3.text = SQNSLocalString(@"3: 您的账号将解除与本产品的授权登陆或绑定关系!");
    label3.font = FONT_REGULAR(14);
    [self.view addSubview:label3];
    [label3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(label2.mas_bottom).offset(26);
            make.centerX.equalTo(self.view);
            make.width.mas_equalTo(SCREEN_WIDETH - 60);
    }];
    
    [self.view addSubview:self.rightBtn];
    [self.rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view.mas_bottom).offset(-FootHeight-40);
        make.height.mas_equalTo(54);
        make.centerX.equalTo(self.view);
        make.width.mas_equalTo(SCREEN_WIDETH - 60);
    }];
    WS(weakSelf);
    [LSTTimer addTimerForTime:16 identifier:@"" handle:^(NSString * _Nonnull day, NSString * _Nonnull hour, NSString * _Nonnull minute, NSString * _Nonnull second, NSString * _Nonnull ms) {
        weakSelf.rightBtn.text = [NSString stringWithFormat:@"%@(%@s)",SQNSLocalString(@"确认注销"),second];
    } finish:^(NSString * _Nonnull identifier) {
        weakSelf.rightBtn.text =  SQNSLocalString(@"确认注销");
        weakSelf.rightBtn.backgroundColor = SQColor(@"#FF3B30");
        weakSelf.rightBtn.textColor = SQColor(@"#FFFFFF");
        weakSelf.rightBtn.SQTouchBtn.enabled = YES;
    } pause:^(NSString * _Nonnull identifier) {
        
    }];
    [self.rightBtn setTouchBlock:^(SQCustomButton * _Nonnull button) {
        [weakSelf SQ_querenzhuxiao];
    }];
}

-(void)SQ_querenzhuxiao{
    [YJProgressHUD SQ_showMsgWithoutView:@""];
    [HttpTool post:Url16 paramDic:[NSMutableDictionary new] successBlock:^(BaseModel * _Nonnull httpModel) {
        [Manager SQ_removeObjectForKey:@"account"];
        [UserModel clearLocalUserModel];
        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[LoginViewController alloc]init]];
         self.view.window.rootViewController = nav;
        } andFailBloc:^(BaseModel * _Nonnull httpModel, NSError * _Nullable error) {
            [YJProgressHUD showMsgWithoutView:httpModel.message];
    }];
   
}


- (SQCustomButton *)rightBtn{
    if (!_rightBtn) {
        _rightBtn = [[SQCustomButton alloc]initType:SQCustomButtonTopImageType imageSize:CGSizeMake(0, 0) midmargin:0];
        _rightBtn.text = SQNSLocalString(@"确认注销");
        _rightBtn.textColor = SQColor999999;
        _rightBtn.font = FONT_REGULAR(16);
        _rightBtn.backgroundColor = SQColor(@"#D8D8D8");
        _rightBtn.SQTouchBtn.enabled = NO;
        _rightBtn.layer.cornerRadius = 10;
    }
    return _rightBtn;
}

@end
